
package com.qf.service.impl;

import java.util.List;

import com.qf.dao.impl.UserDaoImpl;
import com.qf.model.User;
import com.qf.service.UserService;

public class UserServiceImpl implements UserService{

	private UserDaoImpl userDaoImpl = new UserDaoImpl();
	
	@Override
	public boolean findByName(String uname) {
		
		User u=userDaoImpl.findByName(uname); 
		if(u!=null){
			return true;
		}
		//TODO
		return false;
			
	}
	@Override
	public boolean add(User u) {
		String sql="insert into user values(?,?,?,?,?,?,?,?,?,?,?)";
		Object[] params ={u.getUid(),u.getUname(),u.getUpwd(),u.getRealname(),u.getUemail(),u.getUtel(),u.getUbirthday(),u.getUgender(),u.getState(),u.getCode(),u.getUintroduce()};
		int i=userDaoImpl.add(sql,params);
		if(i==1){
			return true;
		}
		//TODO
		return false;
			
	}
	
	@Override
	public boolean findother(String uid, String code) {
		String sql="select * from user where uid=? and code=?";
        Object[] params={uid,code};
        
		List<User> list = userDaoImpl.findother(sql,params);
		if(list.size()>0){
			return true;
		}
		return false;
			
	}
	
	@Override
	public boolean update(String uid) {
		
		int i=userDaoImpl.update(uid);
		if(i==1){
			return true;
		}
		//TODO
		return false;
			
	}
	@Override
	public boolean findNameandPwd(String uname, String upwd) {
		User u=userDaoImpl.findNameandPwd(uname,upwd);
		if(u!=null){
			return true;
		}
		//TODO
		return false;
			
	}
	@Override
	public boolean findBystate(String uname) {
		User u = userDaoImpl.findByName(uname);
		if(u.getState()==1){
			return true;
		}
		//TODO
		return false;
			
	}
	@Override
	public User find(String uname, String upwd) {
		
		//TODO
		return userDaoImpl.findNameandPwd(uname,upwd);
			
	}

}

	